# coding=utf-8

class Hero(object):
    """
    英雄父类
    """

    def __init__(self, name, hp, power):
        """
        :param name: 英雄的名字
        :param hp: 英雄的血量
        :param power: 英雄的攻击力
        """
        super(Hero, self).__init__()
        self.name = name
        self.hp = hp
        self.power = power

    def fight(self, enemy_name, enemy_hp, enemy_power):
        """
        英雄最终的⾎量 = 英雄hp属性-敌⼈的攻击⼒enemy_power
        敌⼈最终的⾎量 = 敌⼈的⾎量enemy_hp-英雄的power属性
        :param enemy_name: 敌人的名字
        :param enemy_hp: 敌人的血量
        :param enemy_power: 敌⼈的攻击⼒
        :return:
        """
        hero_hp = self.hp - enemy_power
        enemy_hp = enemy_hp - self.power
        if hero_hp > enemy_hp:
            print "英雄{}获胜".format(self.name)
        elif hero_hp < enemy_hp:
            print "敌人{}获胜".format(enemy_name)
        else:
            print "双方持平"


class Timo(Hero):
    """
    英雄Timo
    """

    def __init__(self, name, hp, power):
        super(Timo, self).__init__(name, hp, power)


class Jnix(Hero):
    """
    英雄Jnix
    """

    def __init__(self, name, hp, power):
        super(Jnix, self).__init__(name, hp, power)


class HeroFactory(object):
    """
    英雄工厂类
    """

    @staticmethod
    def create_hero(hero_name, hero_hp, hero_power):
        if hero_name == 'Timo':
            return Timo(hero_name, hero_hp, hero_power)
        elif hero_name == 'Jnix':
            return Jnix(hero_name, hero_hp, hero_power)
        else:
            raise Exception("此英雄不在英雄工厂中")


if __name__ == '__main__':
    hero = HeroFactory
    timo = hero.create_hero('Timo', input("Timo的血量："), input("Timo的攻击力："))
    jnix = hero.create_hero('Jnix', input("Jnix的血量："), input("Jnix的攻击力："))
    timo.fight(jnix.name, jnix.hp, jnix.power)
